# from app.user.models import User
from flask import render_template, flash, redirect, session, url_for, request, g
from flask_login import current_user
from exlib.restviewset.response import Response
from exlib.restviewset.reqparse import RequestParser
from exlib.restplus.resource import ListResource, SingleResource, LoginActionResource, ActionResource
from ..forms import LoginForm


class LoginView(ActionResource):
    def get(self):
        if current_user.is_authenticated:
            return redirect(url_for('index'))
        else:
            form = LoginForm()
            return render_template('login.html',
                                   title='Sign In',
                                   form=form)

    poster = RequestParser()
    poster.add_argument('username', type=str, help='用户名')
    poster.add_argument('password', type=str, help='用户名')

    def post(self):
        pass
